require(['./config'], () => {
    require(['cookie', 'header','footer'], (cookie) => {
       class Index {
           constructor () {
            this.Data()
           }
           Data () {
               $('.dl-btn').on('click', function () {
                   var name=$('#name').val()
                   var pwd=$('#pwd').val()
                   var IsChecked=$("#check_1").is(':checked')
                   $.post('/cake/dist/api/login.php', {name, pwd}, resp => {
                        if(resp.code === 200) {
                            if (IsChecked) {
                                $.cookie('name', 'name', { expires: 7, path: '/' })   
                            } else {
                                $.cookie('name', name, {path: '/' })   
                            }
                            alert(resp.body.msg + '，即将返回首页')
                            location.replace('/index.html')
                        }else {
                            alert(resp.body.msg)
                        }
                   },'json')
               })
           }
       }
       new Index()
    })
})
